using AdmissionQA.Domain.Repositorys;
using AdmissionQA.Infrastructure.Date;
using AdmissionQA.Infrastructure.Repositorys;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace AdmissionQA.Infrastructure;

public static class ServiceCollectionExtension
{
    public static void AddInfrastructure(
        this IServiceCollection services,
        IConfiguration configuration
    )
    {
        services.AddDbContext<AdmissionQADbContext>(options =>
        {
            options.UseNpgsql(configuration.GetConnectionString("pgsql"));
        }, ServiceLifetime.Scoped);

        services.AddScoped(typeof(IRepository<>), typeof(EFRepository<>));
    }
}
